﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <script src="http://code.jquery.com/jquery-latest.js"></script>

    <link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css" type="text/css" media="screen" />

    <script type="text/javascript" src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>

    <link href="skin/default/main.css" rel="stylesheet" type="text/css" />

    <script src="jquery.ui.uapselector.js" type="text/javascript"></script>

    <script>

        var userList = [{ id: 652382423, name: "燃烧的思念", py: "rsdsn" }, { id: 677875355, name: "kid", py: "kid" }, { id: 677347434, name: "*疯^_^子*", py: "*f^_^z*" }, { id: 88056681, name: "kevin", py: "kevin" }, { id: 190269, name: "林斌", py: "lb" }, { id: 101691, name: "聖域", py: "ly" }, { id: 103400, name: "李正", py: "lz" }, { id: 680380640, name: "狼外婆", py: "lwp" }, { id: 487420530, name: "Jessie", py: "Jessie" }, { id: 162586725, name: "音乐日记", py: "ylrj" }, { id: 562226183, name: "郑龙珠", py: "zlz" }, { id: 178241526, name: "KityMarry", py: "KityMarry" }, { id: 1774328, name: "李柏", py: "lb" }, { id: 642208422, name: "小鱼", py: "xy" }, { id: 434571008, name: "李村长", py: "lcc" }, { id: 568858732, name: "刘昌辉", py: "lch" }, { id: 613122574, name: "", py: "" }, { id: 643158288, name: "习文晋", py: "xwj" }, { id: 704613886, name: "没有明天", py: "mymt" }, { id: 400000261, name: "小胖", py: "xp" }, { id: 124043046, name: "APTX498", py: "APTX498" }, { id: 36375981, name: "太风流", py: "tfl" }, { id: 82259944, name: "自立", py: "zl" }, { id: 376873307, name: "collinye", py: "collinye" }, { id: 587775883, name: "聖域", py: "ly" }, { id: 811488071, name: "蝶谷云山", py: "dgys" }, { id: 553123407, name: "№歆δ小诺℃", py: "№zδxn℃" }, { id: 561610517, name: "帅帅", py: "ss" }, { id: 624205220, name: "蔡晓希", py: "cxx" }, { id: 99909645, name: "月影", py: "yy" }, { id: 642848505, name: "这是什么", py: "zssm" }, { id: 87787524, name: "豆神之光", py: "dszg" }, { id: 558734214, name: "真实头像", py: "zstx" }, { id: 827340885, name: "李晓勇", py: "lxy" }, { id: 330352561, name: "梦露露", py: "mll" }, { id: 863233285, name: "我没老", py: "wml" }, { id: 530163822, name: "李萌", py: "lm" }, { id: 302531366, name: "叶小小", py: "yxx" }, { id: 52726541, name: "雷小", py: "lx" }, { id: 545666838, name: "刘宗华", py: "lzh" }, { id: 454054265, name: "虚空小箭", py: "xkxj" }, { id: 79911814, name: "赤红燕", py: "chy" }, { id: 173368227, name: "陈超", py: "cc" }, { id: 633622443, name: "", py: "" }, { id: 828007631, name: "李彦品", py: "lyp" }, { id: 8218716, name: "zz", py: "zz" }, { id: 270050546, name: "Oo菰箪oO", py: "Ooz箪oO" }, { id: 164367653, name: "狂武", py: "kw" }, { id: 173454, name: "单摆", py: "db" }, { id: 574081636, name: "啊郎", py: "al" }, { id: 644704221, name: "决口不提∶爱你", py: "jkbt∶an" }, { id: 802426877, name: "华安9527", py: "ha9527" }, { id: 566461480, name: "第一滴眼泪", py: "dydyl" }, { id: 573834206, name: "乐乐", py: "ll" }, { id: 527875473, name: "杨华", py: "yh"}];


        $(document).ready(function() {
            var selector = new NDUAP.Selector({ divID: "divSelector", searchData: userList, width: 500 });
            selector.setValue([{ id: 652382423, name: "燃烧的思念" }, { id: 677347434, name: "*疯^_^子*"}]);
            
            module("选择组件通用方法测试");
            test('String.prototype.enLength()', function() {
                ok("123".enLength() == 3, '"123".enLength() == 3');
                ok("一二三".enLength() == 6, '"一二三".enLength() == 6');
                ok("123一二三".enLength() == 9, '"123一二三".enLength() == 9');


            });

            module("选择组件属性测试");
            test('selector.opts', function() {
                ok(selector.opts.divID == "divSelector", 'selector.opts.divID == "divSelector"');
                ok(selector.opts.width == 500, 'selector.opts.width == 500');
                ok(selector.opts.noDataTip == NDUAP.Selector.Defaults.noDataTip, 'selector.opts.noDataTip == NDUAP.Selector.Defaults.noDataTip == "' + NDUAP.Selector.Defaults.noDataTip + '"');
            });


            module("选择组件功能测试");
            test('selector.getValue()', function() {
                ok(selector.getValue().length == 2, 'selector.getValue().length==2');
                ok(selector.getValue()[0].name == "燃烧的思念", 'selector.getValue()[0].name == "燃烧的思念"');
            });





        });
    </script>

    <script>
        //        //定义测试模块
        //        module("测试示例");
        //        //定义一个简单的函数，判断参数是不是数字
        //        function simpleTest(para) {
        //            if (typeof para == "number") {
        //                return true;
        //            }
        //            else {
        //                return false;
        //            }
        //        }
        //        //开始单元测试
        //        test('simpleTest()', function() {
        //            //列举各种可能的情况
        //            ok(simpleTest(2), '2是一个数字');
        //            ok(!simpleTest("2"), '"2"不是一个数字');
        //        });

        //        //定义一个简单的函数，返回数字和2的乘积
        //        function simpleTest1(para) {
        //            return para * 2;
        //        }
        //        //开始单元测试
        //        test('simpleTest1()', function() {
        //            //列举各种可能的情况
        //            equals(simpleTest1(2), 4, '2 * 2 等于 4');
        //            equals(simpleTest(2), 3, '2 * 2 等于 3');
        //        });

        //        //定义一个简单的函数，返回一个数组
        //        function simpleTest2() {
        //            return [1, 2];
        //        }
        //        //开始单元测试
        //        test('simpleTest2()', function() {
        //            //列举各种可能的情况
        //            equals(simpleTest2(), [1, 2], '函数返回数组[1, 2]');
        //            equals(simpleTest2(), [1, 1], '函数返回数组[1, 1]');
        //        });

        //        //异步测试
        //        module("异步测试示例");
        //        //setTimeout
        //        test('asynchronous test', function() {
        //            // 暂停测试
        //            stop();

        //            setTimeout(function() {
        //                ok(true, '完成运行');
        //                //待测试完成后，恢复
        //                start();
        //            }, 100)
        //        })
        //        //另一种形式
        //        asyncTest('asynchronous test', function() {
        //            setTimeout(function() {
        //                ok(true);
        //                //待测试完成后，恢复
        //                start();
        //            }, 100)
        //        })
 
    </script>

</head>
<body>
    <h1 id="qunit-header">
        QUnit example</h1>
    <h2 id="qunit-banner">
    </h2>
    <h2 id="qunit-userAgent">
    </h2>
    <ol id="qunit-tests">
    </ol>
    <div>
        <div id="divSelector">
        </div>
    </div>
</body>
</html>
